<template>
    <view style="padding: 40rpx;">
        <view>
            <view style="font-size: 18px; margin-bottom: 20rpx;">目录</view>

            <u-collapse style="margin-top: 20rpx;" :value="['0']">
                <u-collapse-item v-for="(childTiem, childIndex) in practiceDtat" :key="childTiem.id"
                    :title="childTiem.structName" :name="childIndex" style="margin: 0;">
                    <a v-for="(questions, questionsIndex) in childTiem.children" :key="questions.id"
                        @click="() => onJump(childTiem, questions)" style="margin-bottom: 30rpx;">
                        {{ questions.name }} ({{ questions.practiceNum || 0 }}/{{ questions.itemNums
                            || 0 }})
                    </a>
                </u-collapse-item>
            </u-collapse>

        </view>
    </view>
</template>

<script>
import { listPractice, startPractice } from '../services/QuestionBankService';

export default {
    data() {
        return {
            marketId: '',
            practiceDtat: []
        }
    },
    onLoad(option) {
        this.marketId = option.marketId
      
    },
    computed: {},
    methods: {
        onListPractice() {
            listPractice({ marketId: this.marketId, practiceType: 2 }).then(res => {
                this.practiceDtat = res.children
            })
        },
        // 章节跳转 
        onJump(item, childTiem) {
            console.log(childTiem, 'childTiem')
         
            startPractice({ practiceUuid: childTiem.practiceUuid || '', marketId: this.marketId, practiceType: 2, structUuid:childTiem.structUuid, itemType: '' }).then(res => {
                uni.navigateTo({
                    url: '/pages/practiceTesting/exercisesPage?practiceUuid=' + res + '&video=true'
                })
            })
        },
    },
    onShow() {
        this.onListPractice()   
    },

}
</script>

<style lang="scss">
page {
    background: #ffffff !important;
}
.u-line.data-v-e778bab2 {
	display: none;
}
</style>